package com.demo.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.common.lang.Result;
import com.demo.entity.Category;
import com.demo.entity.SysDriver;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 司机Controller
 * 
 * @author 1111
 * @date 2023-12-02
 */
@RestController
@RequestMapping("/system/driver")
public class SysDriverController extends BaseController
{

    /**
     * 查询司机列表
     */
    @GetMapping("/list")
    public Result list(SysDriver sysDriver)
    {

        QueryWrapper<SysDriver> wrapper = new QueryWrapper<>(sysDriver);
        Page<SysDriver> page = sysDriverService.page(getPage(), wrapper);
        return Result.succ(page);
    }

    /**
     * 获取司机详细信息
     */
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.succ(sysDriverService.selectSysDriverById(id));
    }

    /**
     * 新增司机
     */
    @PostMapping
    public Result add(@RequestBody SysDriver sysDriver)
    {
        return Result.reselut(sysDriverService.insertSysDriver(sysDriver));
    }

    /**
     * 修改司机
     */
    @PutMapping
    public Result edit(@RequestBody SysDriver sysDriver)
    {
        return Result.reselut(sysDriverService.updateSysDriver(sysDriver));
    }

    /**
     * 删除司机
     */
    @DeleteMapping
    public Result remove( Long[] ids)
    {
        return Result.reselut(sysDriverService.deleteSysDriverByIds(ids));
    }


}
